

STATIC	:= libmtdev.a
DYNAMIC	:= libmtdev.so

CFLAGS := -DHAVE_CONFIG_H -I. -I.. -I../include/ -g -O2


SOURCE  := $(wildcard *.c)

STATIC_OBJ	:= $(patsubst %.c,%_static.o,$(SOURCE))
DYNAMIC_OBJ	:= $(patsubst %.c,%_dynamic.o,$(SOURCE))

TARGET	:= $(STATIC) $(DYNAMIC)



all : $(TARGET)


$(STATIC) : $(STATIC_OBJ)
	ar cr $@ $(STATIC_OBJ)
	ranlib $@

$(STATIC_OBJ) : %_static.o : %.c
	@mkdir -pv .libs .deps
	gcc $(CFLAGS) -MT $(basename $<).lo -MD -MP -MF .deps/$(basename $<).Tpo -c $< -o $@ >/dev/null 2>&1


$(DYNAMIC) : libmtdev.so.1.0.0
	@ln -sv $< libmtdev.so.1
	@ln -sv $< $@

libmtdev.so.1.0.0 : $(DYNAMIC_OBJ)
	gcc -shared -fPIC -DPIC $(DYNAMIC_OBJ) -O2 -Wl,-soname -Wl,libmtdev.so.1 -o $@


$(DYNAMIC_OBJ) : %_dynamic.o : %.c
	@mkdir -pv .libs .deps
	gcc $(CFLAGS) -MT $(basename $<).lo -MD -MP -MF .deps/$(basename $<).Tpo -c $< -fPIC -DPIC -o $@


clean : 
	rm -rfv $(TARGET) $(STATIC_OBJ) $(DYNAMIC_OBJ) *.so* .deps .libs


